import zlib

file_path = "output/1_res"
file_names = ["WORD_Text", "WORD_Indx"]

m_iCryptoKey = 0xA2


def 解密(file_name):
    with open(f"{file_path}/{file_name}", "rb") as f:
        data = bytearray(f.read())

    for i in range(len(data)):
        v = i + m_iCryptoKey + 0x23D
        v *= m_iCryptoKey
        v ^= i % 7
        data[i] ^= v & 0xFF

    with open(f"output/2_res/{file_name}" + ".txt", "wb") as f:
        f.write(zlib.decompress(data))


for name in file_names:
    解密(name)
